<template>
  <el-input v-model="query" :placeholder="placeholder" class="search-input" @keyup.enter="search">
    <template #append>
      <el-button style="vertical-align: middle" @click="search">
        <el-icon>
          <Search />
        </el-icon>
      </el-button>
    </template>
  </el-input>
</template>

<script lang="ts" setup>
import { computed, defineEmits, defineProps } from 'vue'
const props = defineProps({
  modelValue: {
    type: [String, Number],
    default: '',
  },
  placeholder: {
    type: String,
    default: '输入受试者编码精确查询',
  },
})

const emits = defineEmits(['update:modelValue', 'search'])

const query = computed({
  get() {
    return props.modelValue
  },
  set(val) {
    emits('update:modelValue', val)
  },
})

const search = () => {
  emits('search')
}
</script>

<style lang="scss">
.search-input {
  .el-input__inner {
    width: 180px;
  }
}
</style>
